<?php

class database {
	private $name;
	private $server;
	private $username;
	private $password;
	private $database;
	
	/*
	 * Connects to a database within the class attributes specified
	 */
	public function connect(){		
		$this->database = mysql_connect($this->server, $this->username, $this->password);
		if($this->database){			
			if(!mysql_select_db($this->name)){
				echo "MYSQL_ERROR: No database selected\n";
				return FALSE;
			}
			else
				return $this->database;
		}
		else{
			echo "MYSQL_ERROR: Connection error\n";
			return FALSE;
		}
	}
	
	/*
	 * Disconnects the database resource
	 */
	public function disconnect(){
		mysql_close($this->database);	
	}
	
	public function setName($name){
		$this->name = $name;
	}
	
	public function setServer($server){
		$this->server = $server;
	}
	
	public function setUserName($userName){
		$this->username = $userName;
	}
	
	public function setPassword($password){
		$this->password = $password;
	}
}

class databaseTournament extends database{
	public function __construct(){
		$this->setName("tournament");/*p6jtournaments */
		$this->setServer("localhost");
		$this->setUserName("ladder");/*p6jtournaments */
		$this->setPassword("ladder");
	}
}

class databaseForum extends database{
	public function __construct(){
		$this->setName("p6jsmfforum");
		$this->setServer("188.121.42.46");
		$this->setUserName("p6jsmfforum");
		$this->setPassword("Disturbanc3");
	}
}

class databaseLocal extends database{
	public function __construct(){
		$this->setName("pes6jtournament"); 	/*p6jtournaments */
		$this->setServer("localhost");
		$this->setUserName("ladder");			/*p6jtournaments */
		$this->setPassword("ladder");
	}
}

?>